#include "process_bar.h"
#include<string.h>
#include <unistd.h>

const char* lable="|/-\\";
char bar[NUM];

#define GREEN "\033[0;32;32m"//颜色绿色设置代码
#define NONE "\033[m"//白色的设置代码



void processbar(int rate)
{
    if(rate<0 || rate>100) return;

    int len=strlen(lable);
    printf("[%-100s][%d%%][%c]\r", bar, rate, lable[rate%len]); //??
    fflush(stdout);//清空缓冲区
    bar[rate++]=BODY;
    if(rate<100) bar[rate]=RIGHT;
}
void initbar()
{
    memset(bar,'\0',sizeof(bar));
}